<?
include("include/role.php");
include("include/mysql.config.php");
?>
<!DOCTYPE html>
<html>
<head>
    <title>管理界面</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="asset/admin.css" rel="stylesheet" type="text/css">
    <link href="asset/apprise.css" rel="stylesheet" type="text/css">
    <link href="asset/colorbox/colorbox.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="asset/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="asset/colorbox/jquery.colorbox.js"></script>
<script type="text/javascript" src="asset/apprise-1.5.full.js"></script>
<script type="text/javascript" src="asset/admin.js"></script>
<script>
$(function(){
    $(".del").click(function(){
        var o=$(this);
         if(getBroswer()=='IE6'){
             if(window.confirm("确定要删除？")){
                doDel(o);
             }
            }                  
            else{
                apprise('确定要删除?', {'verify':true}, function(r){
                if(r){
                doDel(o);
                } 
            });
            }

        
        return false;
    });
});

</script>
</head>
<body>
<?
//消息回调
$message=$_SESSION['message'];
if($message!=null){
    echo "<script>
            if(getBroswer()=='IE6'){
                alert('$message');
            }                  
            else{
            apprise('$message');
            }
        </script>";


    unset($_SESSION['message']);
    }
   

?>
<?
$page=$_GET['page'];
$page=$page==null?0:$page;
$size=20;

$sql="select * from massage order by id desc limit ".$page*$size.",".$size;
$countsql="select count(*) from  massage";
$result=mysql_query($sql);
$cResult=mysql_query($countsql);
$rows=mysql_array($result);
$count=mysql_array($cResult);
$count=$count[0][0];
?>
<? include("include/menu.php"); ?>
<table class="list-table">
<caption class="table-caption">信息管理</caption>
<colgroup>
<col width='5%' ></col>
<col width='10%'></col>
<col width='15%'></col>
<col width='10%'></col>
<col width='5%'></col>
<col width='10%'></col>
<col width='10%'></col>
<col width='10%'></col>
<col width='10%'></col>
<col ></col>
<col width='5%'></col>
</colgroup>
<thead>
    <tr>
    <td colspan=11>
    <span style='color:#cccccc'>当前第<?echo $page+1 ?>页,每页<? echo $size ?>条记录,共<?echo ceil($count/$size)-1?>页</span>
    <?if($page>0){?>
    <a href="admin.php?page=0">首页</a>
    <?}?>
    <?if($page>0){ ?>
    <a href="admin.php?page=<?echo $page-1?>">上一页</a>
    <?}?>
    |
    <?if($page<($count/$size-1)){?>
    <a href="admin.php?page=<?echo $page+1?>">下一页</a>
    <? }?>
    <?if($page<($count/$size-1)){?>
    <a href="admin.php?page=<?echo ceil($count/$size)-1?>">尾页</a>
    <?}?>
    </td>
    </tr>
</thead>

<tr>
<? foreach($rows[0] as $key=>$value){ ?>

<?
$pattern="/^[0-9]+$/";
if($key){
    if(!preg_match($pattern,$key)){

        echo "<th>";
        echo $key;
        echo "</th>";
    }
}
?>

<? } ?>
<th>操作</th>

</tr>
<? for($i=0;$i<count($rows);$i++){
    
?>
<tr>
    <? foreach($rows[$i] as $key=>$value){ ?>
<?
    $pattern="/^[0-9]+$/";

    if(!preg_match($pattern,$key)){
            echo "<td>";
            echo $value;
            echo "</td>";
    }

?>

<? } ?>
<td>
<a class="del" href="addProduct.php?ac=del&id=<?echo $rows[$i]['id'] ?>" >[删除]</a>
</td>
</tr>
<? } ?>
<tfoot>
<tr><td colspan=11>
 <span style='color:#cccccc'>当前第<?echo $page+1 ?>页,每页<? echo $size ?>条记录,共<?echo ceil($count/$size)-1?>页</span>
    <?if($page>0){?>
    <a href="admin.php?page=0">首页</a>
    <?}?>
    <?if($page>0){ ?>
    <a href="admin.php?page=<?echo $page-1?>">上一页</a>
    <?}?>
    |
    <?if($page<($count/$size-1)){?>
    <a href="admin.php?page=<?echo $page+1?>">下一页</a>
    <? }?>
    <?if($page<($count/$size-1)){?>
    <a href="admin.php?page=<?echo ceil($count/$size)-1?>">尾页</a>
    <?}?>

</td><tr>
</tfoot>
</table>

</body>
</html>
